from create import session
from create_otm import UserOtm, Role

res = session.query(UserOtm, Role).join(Role).all() # 查询所有用户，及对应的role_id
print(res)

res1 = session.query(UserOtm.name, Role.role_name).join(Role).all() # 查询所有用户和角色
print(res1)

res2 = session.query(UserOtm.name, Role.role_name).join(Role, isouter=True).filter(Role.role_name == 'sa').all() # 查询所有DBA的用户
print(res2)